<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring 注解深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .annotation-card {
            background: linear-gradient(145deg, #ffffff, #f3f4f6);
            border: 1px solid rgba(0,0,0,0.05);
        }
        .code-style {
            background: #2d3748;
            color: #48bb78;
            padding: 2px 8px;
            border-radius: 4px;
            font-family: 'Consolas', 'Monaco', monospace;
            font-size: 0.9em;
        }
        .first-letter {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            font-weight: 700;
            color: #667eea;
        }
        .section-divider {
            background: linear-gradient(to right, transparent, #667eea, transparent);
            height: 2px;
            margin: 3rem 0;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        .source-image {
            border-radius: 8px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
            transition: transform 0.3s ease;
        }
        .source-image:hover {
            transform: scale(1.02);
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6 text-center">
            <h1 class="text-5xl md:text-6xl font-bold mb-4">
                <i class="fas fa-code mr-4"></i>Spring 注解深度解析
            </h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">探索 @Service、@Controller、@Component 和 @Repository 的奥秘</p>
            <div class="flex justify-center space-x-4">
                <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full">
                    <i class="fas fa-layer-group mr-2"></i>组件管理
                </span>
                <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full">
                    <i class="fas fa-project-diagram mr-2"></i>架构设计
                </span>
                <span class="bg-white bg-opacity-20 px-4 py-2 rounded-full">
                    <i class="fas fa-book mr-2"></i>最佳实践
                </span>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- Introduction -->
        <section class="bg-white rounded-lg shadow-xl p-8 mb-12">
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="first-letter">在</span>Spring框架的世界里，<span class="code-style">@Service</span>、<span class="code-style">@Controller</span>、<span class="code-style">@Component</span>和<span class="code-style">@Repository</span>是构建应用程序的基石。这些注解不仅仅是简单的标记，它们代表着Spring IoC容器中不同层次的组件，各自承担着独特的职责。让我们深入探索这些注解的本质，理解它们在现代Spring应用中的重要作用。
            </p>
        </section>

        <!-- Annotations Grid -->
        <section class="grid md:grid-cols-2 gap-8 mb-12">
            <!-- @Component -->
            <div class="annotation-card rounded-lg p-8 card-hover">
                <div class="flex items-center mb-4">
                    <div class="bg-purple-100 p-3 rounded-full mr-4">
                        <i class="fas fa-cube text-purple-600 text-2xl"></i>
                    </div>
                    <h3 class="text-2xl font-bold text-gray-800">@Component</h3>
                </div>
                <p class="text-gray-600 leading-relaxed mb-4">
                    作为最通用的组件注解，<span class="code-style">@Component</span>是所有Spring管理组件的基础。它可以标注在任何类上，将其转化为Spring Bean。
                </p>
                <div class="bg-gray-50 p-4 rounded-lg">
                    <p class="text-sm text-gray-500 mb-2"><i class="fas fa-lightbulb mr-2"></i>适用场景</p>
                    <ul class="text-gray-700 space-y-1">
                        <li><i class="fas fa-check text-green-500 mr-2"></i>工具类和辅助类</li>
                        <li><i class="fas fa-check text-green-500 mr-2"></i>通用组件</li>
                        <li><i class="fas fa-check text-green-500 mr-2"></i>不属于特定层的类</li>
                    </ul>
                </div>
            </div>

            <!-- @Service -->
            <div class="annotation-card rounded-lg p-8 card-hover">
                <div class="flex items-center mb-4">
                    <div class="bg-blue-100 p-3 rounded-full mr-4">
                        <i class="fas fa-cogs text-blue-600 text-2xl"></i>
                    </div>
                    <h3 class="text-2xl font-bold text-gray-800">@Service</h3>
                </div>
                <p class="text-gray-600 leading-relaxed mb-4">
                    <span class="code-style">@Service</span>是<span class="code-style">@Component</span>的特化版本，专门用于标识服务层组件，承载业务逻辑的核心实现。
                </p>
                <div class="bg-gray-50 p-4 rounded-lg">
                    <p class="text-sm text-gray-500 mb-2"><i class="fas fa-lightbulb mr-2"></i>适用场景</p>
                    <ul class="text-gray-700 space-y-1">
                        <li><i class="fas fa-check text-green-500 mr-2"></i>业务逻辑实现</li>
                        <li><i class="fas fa-check text-green-500 mr-2"></i>事务管理</li>
                        <li><i class="fas fa-check text-green-500 mr-2"></i>复杂计算处理</li>
                    </ul>
                </div>
            </div>

            <!-- @Controller -->
            <div class="annotation-card rounded-lg p-8 card-hover">
                <div class="flex items-center mb-4">
                    <div class="bg-green-100 p-3 rounded-full mr-4">
                        <i class="fas fa-globe text-green-600 text-2xl"></i>
                    </div>
                    <h3 class="text-2xl font-bold text-gray-800">@Controller</h3>
                </div>
                <p class="text-gray-600 leading-relaxed mb-4">
                    <span class="code-style">@Controller</span>标识Spring MVC中的控制器，负责处理HTTP请求，协调视图和模型之间的交互。
                </p>
                <div class="bg-gray-50 p-4 rounded-lg">
                    <p class="text-sm text-gray-500 mb-2"><i class="fas fa-lightbulb mr-2"></i>适用场景</p>
                    <ul class="text-gray-700 space-y-1">
                        <li><i class="fas fa-check text-green-500 mr-2"></i>Web请求处理</li>
                        <li><i class="fas fa-check text-green-500 mr-2"></i>视图渲染控制</li>
                        <li><i class="fas fa-check text-green-500 mr-2"></i>RESTful API端点</li>
                    </ul>
                </div>
            </div>

            <!-- @Repository -->
            <div class="annotation-card rounded-lg p-8 card-hover">
                <div class="flex items-center mb-4">
                    <div class="bg-yellow-100 p-3 rounded-full mr-4">
                        <i class="fas fa-database text-yellow-600 text-2xl"></i>
                    </div>
                    <h3 class="text-2xl font-bold text-gray-800">@Repository</h3>
                </div>
                <p class="text-gray-600 leading-relaxed mb-4">
                    <span class="code-style">@Repository</span>专门用于数据访问层，标识DAO类，提供数据持久化的抽象层。
                </p>
                <div class="bg-gray-50 p-4 rounded-lg">
                    <p class="text-sm text-gray-500 mb-2"><i class="fas fa-lightbulb mr-2"></i>适用场景</p>
                    <ul class="text-gray-700 space-y-1">
                        <li><i class="fas fa-check text-green-500 mr-2"></i>数据库访问</li>
                        <li><i class="fas fa-check text-green-500 mr-2"></i>数据持久化</li>
                        <li><i class="fas fa-check text-green-500 mr-2"></i>异常转换处理</li>
                    </ul>
                </div>
            </div>
        </section>

        <div class="section-divider"></div>

        <!-- Architecture Visualization -->
        <section class="bg-white rounded-lg shadow-xl p-8 mb-12">
            <h2 class="text-3xl font-bold text-gray-800 mb-6 text-center">
                <i class="fas fa-sitemap mr-3"></i>Spring 注解架构关系图
            </h2>
            <div class="mermaid">
                graph TD
                    A[@Component] --> B[@Service]
                    A --> C[@Controller]
                    A --> D[@Repository]
                    B --> E[业务逻辑层]
                    C --> F[表现层]
                    D --> G[数据访问层]
                    
                    style A fill:#9F7AEA,stroke:#6B46C1,stroke-width:2px,color:#fff
                    style B fill:#4299E1,stroke:#2B6CB0,stroke-width:2px,color:#fff
                    style C fill:#48BB78,stroke:#2F855A,stroke-width:2px,color:#fff
                    style D fill:#ED8936,stroke:#C05621,stroke-width:2px,color:#fff
            </div>
        </section>

        <!-- Source Code Section -->
        <section class="bg-white rounded-lg shadow-xl p-8 mb-12">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 text-center">
                <i class="fas fa-code mr-3"></i>源码展示
            </h2>
            <div class="grid md:grid-cols-2 gap-6">
                <div class="text-center">
                    <h3 class="text-xl font-semibold text-gray-700 mb-4">@Component 注解源码</h3>
                    <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1649727733524-22151cea-af7e-4b63-a23b-d297a454d658.png" 
                         alt="@Component源码" 
                         class="source-image w-full">
                </div>
                <div class="text-center">
                    <h3 class="text-xl font-semibold text-gray-700 mb-4">@Service 注解源码</h3>
                    <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1649727773611-de119828-f864-4047-ba9c-d9c204f1b4fc.png" 
                         alt="@Service源码" 
                         class="source-image w-full">
                </div>
                <div class="text-center">
                    <h3 class="text-xl font-semibold text-gray-700 mb-4">@Controller 注解源码</h3>
                    <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1649727815148-db098a90-6501-45f9-b720-0705d549fbce.png" 
                         alt="@Controller源码" 
                         class="source-image w-full">
                </div>
                <div class="text-center">
                    <h3 class="text-xl font-semibold text-gray-700 mb-4">@Repository 注解源码</h3>
                    <img src="https://cdn.nlark.com/yuque/0/2022/png/21449790/1649727842228-2aaa7c9f-e6cf-4aa4-82b5-322c7b62420d.png" 
                         alt="@Repository源码" 
                         class="source-image w-full">
                </div>
            </div>
        </section>

        <!-- Best Practices -->
        <section